<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    
    <head>
        <meta charset="utf-8">
        <title>X-admin v1.0</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="/woniu/Public/X-admin/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" method="post" action="" >
              <input type="hidden" name='id' value="<?php echo ($good[0]['id']); ?>">
            	<table class="layui-table" lay-skin="nob" width='600px' >
                       <tr>
                        
                          <th>
                            <label for="L_email" class="layui-form-label">班级名</label>
                          </th> 
                        
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                              <input type="text" name="classname"  value="<?php echo ($good[0]['name']); ?>" lay-verify="required" class="layui-input" <?php echo ($disabled); ?>>   
                            </div>  
                          </td>
                          <th>
                            <label for="L_email" class="layui-form-label">班主任</label>
                          </th> 
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                            <select name="admin" lay-verify="required" <?php echo ($disabled); ?>>
                                <option value=''>--请选择--</option>
                                <?php if(is_array($admin)): foreach($admin as $key=>$row): ?><option value="<?php echo ($row['id']); ?>" <?php if($good[0]['admin_id'] == $row['id']): ?>selected<?php endif; ?>><?php echo ($row['name']); ?></option><?php endforeach; endif; ?>
                            </select>    
                            </div>     
                          </td>
                         
                        </tr>

                        <tr>

                          <th>
                            <label for="L_email" class="layui-form-label">讲师</label>
                          </th> 
                        
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                            <select name="teacher" lay-verify="required" <?php echo ($disabled); ?>>
                               <option value="">--请选择--</option>
                               <?php if(is_array($teacher)): foreach($teacher as $key=>$row): ?><option value="<?php echo ($row['id']); ?>" <?php if($good[0]['teacher_id'] == $row['id']): ?>selected<?php endif; ?>><?php echo ($row['name']); ?></option><?php endforeach; endif; ?>
                            </select>    
                            </div>  
                          </td>
                          <th>
                            <label for="L_email" class="layui-form-label">项目经理</label>
                          </th> 
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                            <select name="pm" lay-verify="required" <?php echo ($disabled); ?>>
                               <option value="">--请选择--</option>
                               <?php if(is_array($pm)): foreach($pm as $key=>$row): ?><option value="<?php echo ($row['id']); ?>" <?php if($good[0]['pm_id'] == $row['id']): ?>selected<?php endif; ?>><?php echo ($row['name']); ?></option><?php endforeach; endif; ?>
                            </select>    
                            </div>     
                          </td>
                         
                        </tr>

                        <tr>
                        
                          <th>
                            <label for="L_email" class="layui-form-label">开班时间</label>
                          </th> 
                        
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                             <input class="layui-input" name='start' placeholder="开始日" value="<?php echo ($good[0]['start_time']); ?>"id="LAY_demorange_s" <?php echo ($disabled); ?>>
                            </div>  
                          </td>

                          <th>
                            <label for="L_email" class="layui-form-label">专业</label>
                          </th> 
                        
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                            <select name="major" <?php echo ($disabled); ?>>
                              <option value=''>--请选择--</option>
                              <?php if(is_array($major)): foreach($major as $key=>$row): ?><option value="<?php echo ($row['id']); ?>" <?php if($good[0]['major_id'] == $row['id']): ?>selected<?php endif; ?>><?php echo ($row['name']); ?></option><?php endforeach; endif; ?>
                            </select>    
                            </div>  
                          </td>
                         
                        </tr> 
                     
                        <tr>
                          <th>
                            <label for="L_email" class="layui-form-label">毕业时间</label>
                          </th>

                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                            <input class="layui-input" name='end' placeholder="截止日" value="<?php echo ($good[0]['end_time']); ?>"  id="LAY_demorange_e" <?php echo ($disabled); ?>> 
                            </div>     
                          </td>
                          
                          <th>
                            <label for="L_email" class="layui-form-label">状态</label>
                          </th> 
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                              <select name="status" <?php echo ($disabled); ?>>
                                <option value="" >--请选择--</option>
                                <option value='0' <?php if($good[0]['status'] == 0): ?>selected<?php endif; ?>>即将开班</option>
                                <option value='1' <?php if($good[0]['status'] == 1): ?>selected<?php endif; ?>>正常上课</option>
                                <option value='2' <?php if($good[0]['status'] == 2): ?>selected<?php endif; ?>>已毕业</option>
                              </select>    
                            </div>     
                          </td>
                         
                        </tr>

                        <tr>

                          <th>
                            <label for="L_email" class="layui-form-label">教室</label>
                          </th> 
                        
                          <td>
                            <div class="layui-input-inline" style="width:120px;text-align: left">
                            <select name="classroom" <?php echo ($disabled); ?>>
                               <option value="">--请选择--</option>
                               <?php if(is_array($rooms)): foreach($rooms as $key=>$row): ?><option value="<?php echo ($row['id']); ?>" <?php if($good[0]['class_room'] == $row['id']): ?>selected<?php endif; ?>><?php echo ($row['name']); ?></option><?php endforeach; endif; ?>
                            </select>    
                            </div>  
                          </td>
                         
                        </tr>
                        <tr>
                          <td colspan='2' align='center'>
                              <div class="layui-form-item">
                                <?php if($disabled == disabled): ?><button  class="layui-btn" lay-filter="close" lay-submit="">确定</button>
                                  <?php else: ?>
                                  <button  class="layui-btn" lay-filter="add" lay-submit="">修改</button>
                                  <input type="reset" class="layui-btn" value='重置'><?php endif; ?>
                                
                              </div>
                          </td>
                        </tr>
                </table>

                
            </form>
        </div>
        <script src="/woniu/Public/X-admin/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="/woniu/Public/X-admin/js/x-layui.js" charset="utf-8">
        </script>
        <script>

            layui.use(['form','layer','laydate'], function(){
                $ = layui.jquery;
              var form = layui.form();
              var laydate = layui.laydate;
              layer = layui.layer;

              var start = {
                min: laydate.now()
                ,max: '2099-06-16 23:59:59'
                ,istoday: false
                ,choose: function(datas){
                  end.min = datas; //开始日选好后，重置结束日的最小日期
                  end.start = datas //将结束日的初始值设定为开始日
                }
              };
              
              var end = {
                min: laydate.now()
                ,max: '2099-06-16 23:59:59'
                ,istoday: false
                ,choose: function(datas){
                  start.max = datas; //结束日选好后，重置开始日的最大日期
                }
              };
              
              document.getElementById('LAY_demorange_s').onclick = function(){
                start.elem = this;
                laydate(start);
              }
              document.getElementById('LAY_demorange_e').onclick = function(){
                end.elem = this
                laydate(end);
              }
              form.on('submit(close)', function(data){
                var index = parent.layer.getFrameIndex(window.name);
                //关闭当前frame
                parent.layer.close(index);
                // return false;
              })
              //监听提交
              form.on('submit(add)', function(data){
                
                console.log(data);
                id=$("input[name='id']").val();
                classname=$("input[name='classname']").val();
                admin=$("select[name='admin']").val();
                teacher=$("select[name='teacher']").val();
                pm=$("select[name='pm']").val();
                status=$("select[name='status']").val();
                classroom=$("select[name='classroom']").val();
                major=$("select[name='major']").val();
                start=$("input[name='start']").val();
                end=$("input[name='end']").val();
                // post方式添加
                $.post('/woniu/index.php/Home/Classmanage/doupdate',{id:id,classname:classname,admin:admin,teacher:teacher,pm:pm,status:status,classroom:classroom,major:major,start:start,end:end},function(data){
                    // alert(data);
                    if(data=="修改成功"){
                       layer.alert("添加成功", {icon: 6},function () {
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            parent.reload();
                        });
                    }else{
                        alert('数据修改失败');
                        return false;
                    }
                });
                
                return false;
              });
            }); 
        </script>
    </body>

</html>